#include <stdio.h>
#define MAX 512

int facsum(int m) {
    int sum = 1, i = 2;
    while (i <= m / 2) {
        if (m % i == 0) {
            sum += i;
        }
        i++;
    }
    return sum;
}

int main() {
    int m = 3, n, k;
    while (m <= 5000) {
        k = facsum(m);
        n = facsum(k);
        if ( m == n && m <= k) {
            printf("%d, %d\n", m, k);
        }
        m++;
    }
    return 0;
}
